<?php

	namespace Vavilen\FirstBundle\DataFixtures\ORM;

	use Doctrine\Common\DataFixtures\AbstractFixture;
	use Doctrine\Common\DataFixtures\FixtureInterface;
	use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
	use Doctrine\Common\Persistence\ObjectManager;
	use Vavilen\FirstBundle\Entity\User;

	class LoadUserData extends AbstractFixture  implements OrderedFixtureInterface, FixtureInterface
	{
		public function load(ObjectManager $manager)
		{
			$user1 = new User();
			$user1->setUserName('User');
			$user1->setRoles(array('ROLE_USER'));
			$user1->setPlainPassword('user');
			$user1->setEmail('user@email.com');
			$manager->persist($user1);
			$this->addReference('role_user', $user1);

			$user2 = new User();
			$user2->setUserName('Admin');
			$user2->setRoles(array('ROLE_SUPER_ADMIN'));
			$user2->setPlainPassword('admin');
			$user2->setEmail('admin@email.com');
			$manager->persist($user2);
			$this->addReference('role_admin', $user2);

			$manager->flush();
		}

		public function getOrder()
		{
			return 3;
		}
	}